﻿<%@ WebHandler Language="C#" Class="BooksListHandler" %>

using System.Web;
using Bussiness.Interface;
using Bussiness.Service;
using Newtonsoft.Json;
using Model;


public class BooksListHandler : IHttpHandler {

    private static IListInforService _iListInforService = new ListInforService();

    public void ProcessRequest (HttpContext context) {
        if (context.Request["page"] != null && context.Request["limit"] != null)
        {
            string result = "";
            try
            {
                int page = int.Parse(context.Request["page"]);
                int limit = int.Parse(context.Request["limit"]);
                result = JsonConvert.SerializeObject(_iListInforService.ListInfor<Books>(page, limit));
            }
            catch {
                  result = JsonConvert.SerializeObject(false);
            }
            context.Response.Write(result);
        }
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}